﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace cludg.Domain.Content.Stories
{
	public class Comment : IContent
	{
		public virtual string Id { get; set; }

		public virtual Story Story { get; internal protected set; }
		public virtual Comment ParentComment { get; protected set; }
		public virtual Users.User Author { get; set; }
		public virtual DateTime CreationTime { get; set; }
		public virtual string Text { get; set; }
		public virtual string DeletedText { get; set; }
		public virtual bool IsDeleted { get; set; }

		public virtual IEnumerable<Comment> ChildComments
		{
			get { return Story.Comments.Where(x => x.ParentComment != null && x.ParentComment.Id == Id); }
		}

		public virtual void AddChild(Comment comment)
		{
			comment.ParentComment = this;
		}

		public override string ToString()
		{
			return string.Format("<Comment: Id='{0}'>", Id);
		}
	}
}
